﻿<presentation:UserControlView x:Class="Chronos.Client.Win.Views.Main.View"
                              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                              xmlns:presentation="clr-namespace:Rhiannon.Windows.Presentation;assembly=Rhiannon.Windows"
                              xmlns:converters="clr-namespace:Rhiannon.Windows.Presentation.Converters;assembly=Rhiannon.Windows"
                              xmlns:controls="clr-namespace:Rhiannon.Windows.Controls;assembly=Rhiannon.Windows"
                              xmlns:commanding="clr-namespace:Rhiannon.Windows.Presentation.Commands;assembly=Rhiannon.Windows"
                              x:Uid="Profiler_MainView">
    <presentation:UserControlView.Resources>
        <converters:InverseBoolConverter x:Key="InverseBoolConverter" />
        <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
        <Style x:Key="GroupToggleButtonStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="Height" Value="35" />
            <Setter Property="Foreground" Value="#FFFFFF" />
            <Setter Property="Padding" Value="5,0,5,0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border Name="Border" Background="#31B6FD" HorizontalAlignment="Stretch">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Name="ContentSite" Grid.Column="0" FontSize="19" Foreground="{TemplateBinding Foreground}" TextTrimming="CharacterEllipsis"
                                                FontWeight="Thin" Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" Text="{TemplateBinding Content}" />
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="Border" Property="Background" Value="#4ebffc" />
                            </Trigger>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter TargetName="Border" Property="Background" Value="#FFFFFF" />
                                <Setter TargetName="ContentSite" Property="TextBlock.Foreground" Value="#000000" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </presentation:UserControlView.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Background="#31B6FD">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <ItemsControl Grid.Column="0" ItemsSource="{Binding Documents}" HorizontalAlignment="Left" HorizontalContentAlignment="Stretch" VerticalAlignment="Bottom">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <ToggleButton Style="{StaticResource GroupToggleButtonStyle}" Content="{Binding Title}" MinWidth="120" VerticalAlignment="Center"
                                        IsChecked="{Binding IsActive}" IsEnabled="{Binding IsActive, Converter={StaticResource InverseBoolConverter}}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" />
                                
                            </Grid>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal" IsItemsHost="True" HorizontalAlignment="Stretch" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
                <Button Grid.Column="1" Style="{DynamicResource BlurlessImageButton}"
                        Visibility="{Binding IsEnabled, RelativeSource={RelativeSource Self}, Converter={StaticResource BoolToVisibilityConverter}}" 
                        commanding:Event.Command="{Binding CloseDocumentCommand}"
                        commanding:Event.CommandParameter="{Binding Documents.ActiveDocument}"
                        ToolTip="Close active tab">
                    <controls:BlurlessImage Source="pack://application:,,,/Chronos.Client.Win;component/Resources/images/close.png" />
                </Button>
            </Grid>
        </Border>
        <ContentControl Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="{Binding Documents.ActiveDocument.View}" />
        <Border Grid.Row="2" Background="#31B6FD" Height="30">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <controls:BlurlessImage Grid.Column="0" Source="pack://application:,,,/Chronos.Client.Win;component/Resources/images/localmachine.png" Margin="5,0,5,0" />
                <TextBlock Grid.Column="1" Text="{Binding StateMessage}" Foreground="#FFFFFF" />
            </Grid>
        </Border>
    </Grid>
</presentation:UserControlView>